404b5c0cb447941a5545d423eb4f2d02328f4c3f,src/edu/stanford/nlp/util/IntervalTree.java,IntervalTree,contains,#IntervalTree#Interval#,256

Before Change


    return contains(n, Interval.toInterval(p, p));
  }

  public static <E extends Comparable<E>, T extends HasInterval<E>> boolean contains(IntervalTree<E,T> n, Interval<E> target) {
    // Don't search nodes that don't exist
    if (n == null || n.isEmpty())
      return false;

    // If target is to the right of the rightmost point of any interval
    // in this node and all children, there won't be any matches.
    if (target.first.compareTo(n.maxEnd) > 0)
      return false;

    // Check this node
    if (n.value.getInterval().contains(target)) {
      return true;
    }

    // If target is to the left of the start of this interval, then search left
    if (target.second.compareTo(n.value.getInterval().first()) <= 0)  {
      // Search left children
      if (n.left != null) {
        return contains(n.left, target);
      }
    } else {
      if (n.right != null)  {
        return contains(n.right, target);
      }
    }

    return false;
  }

  public static <T, E extends Comparable<E>> List<T> getNonOverlapping(

After Change



  private static <E extends Comparable<E>, T extends HasInterval<E>>
    boolean contains(IntervalTree<E,T> node, Interval<E> target, Function<T,Boolean> containsTargetFunction) {
    IntervalTree<E,T> n = node;

    // Don't search nodes that don't exist
    while (n != null && !n.isEmpty()) {
      IntervalTree<E,T> next = null;

      // If target is to the right of the rightmost point of any interval
      // in this node and all children, there won't be any matches.
      if (target.first.compareTo(n.maxEnd) > 0)
        return false;

      // Check this node
      if (containsTargetFunction.apply(n.value))
        return true;

      // If target is to the left of the start of this interval, then search left
      if (target.second.compareTo(n.value.getInterval().first()) <= 0)  {
        // Search left children
        if (n.left != null) {
          next = n.left;
        }
      } else {
        if (n.right != null)  {
          next = n.right;
        }
      }
      n = next;
    }
    return false;
  }

  public static <T, E extends Comparable<E>> List<T> getNonOverlapping(